<?php

namespace app\admin\validate;

use think\Validate;

class AdminUser extends Validate
{
    protected $rule = [
        'username' => 'require',
        'password' => 'require',
        'captcha' => 'require|checkCaptcha',
    ];

    protected $message = [
        'username.require' => '用户名必须填写',
        'password.require' => '密码必须填写',
        'captcha.require' => '验证码必须填写'
    ];

    protected function checkCaptcha($value, $rule, $data = [])
    {
        if(!captcha_check($value)){
            return "验证码不正确";
        }

        return true;
    }
}